#include "test_list.h"

#ifdef TEST_FIND

#define TEST_CASE_NAME os
#define TEST_NUMBER(n) Find##_##n

#include <os/find.h>
#include <os/xcommand.h>

using namespace os;

#define TEST_FIND_000
#define TEST_FIND_001
#define TEST_FIND_002
#define TEST_FIND_003
#define TEST_FIND_004
#define TEST_FIND_005
#define TEST_FIND_006
#define TEST_FIND_007
#define TEST_FIND_008
#define TEST_FIND_009
#define TEST_FIND_010
#define TEST_FIND_011
#define TEST_FIND_012
#define TEST_FIND_013
#define TEST_FIND_014
#define TEST_FIND_015
#define TEST_FIND_016
#define TEST_FIND_017
#define TEST_FIND_018
#define TEST_FIND_019
#define TEST_FIND_020
#define TEST_FIND_021
#define TEST_FIND_022
#define TEST_FIND_023
#define TEST_FIND_024
#define TEST_FIND_025
#define TEST_FIND_026
#define TEST_FIND_027
#define TEST_FIND_028
#define TEST_FIND_029
#define TEST_FIND_030
#define TEST_FIND_031
#define TEST_FIND_032

//------------------------------------------------------------------------------------------------------//
namespace{

    const os::path& start = WhereProgramIsRunning();
    const os::path& work = start/"tmp";

    void CreateTestWorkspace()
    {
        XCreateFile(work/"workspace/build/some/some.txt");
        XCreateFile(work/"workspace/doc/doc.txt");
        XCreateFile(work/"workspace/external/msvc2013/boost/include/boost/dep.cmake");
        XCreateFile(work/"workspace/external/msvc2013/gtest/include/gtest/dep.cmake");
        XCreateFile(work/"workspace/external/msvc2013/tools/include/tools/dep.cmake");
        XCreateFile(work/"workspace/experiment/exp1/main.cpp");
        XCreateFile(work/"workspace/product/msvc2013/example/bin/example.exe");
        XCreateFile(work/"workspace/project/main.cpp");
        XCreateFile(work/"workspace/service/bat/script.bat");
        XCreateFile(work/"workspace/service/cmake");
        XCreateFile(work/"workspace/service/doc/doc.txt");
        XCreateFile(work/"workspace/utilities/cmd.exe");
    }

}
//------------------------------------------------------------------------------------------------------//

#ifdef TEST_FIND_000
TEST(TEST_CASE_NAME, TEST_NUMBER(000))
{
    if(Exists(work))
        EXPECT_EQ(true,RemoveAll(work));

    CreateTestWorkspace();
    const path location  = work/"workspace/external/msvc2013/tools/include/tools";
    const path workspace = FindPrev(location,"utilities");
    const bool success   = workspace == work/"workspace";
    EXPECT_EQ(true, success);

    if(Exists(work))
        EXPECT_EQ(true,RemoveAll(work));
}
#endif // TEST_FIND_000


#ifdef TEST_FIND_001
TEST(TEST_CASE_NAME,TEST_NUMBER(001))
{
    if(Exists(work))
        EXPECT_EQ(true,RemoveAll(work));

    CreateTestWorkspace();
    const path location   = work/"workspace/external/msvc2013/tools/include/tools";
    const path symptoms[] = { "utilities", "external" };
    const path workspace  = FindPrev(location, symptoms);
    const bool success    = workspace == work/"workspace";
    EXPECT_EQ(true,success);

    if(Exists(work))
        EXPECT_EQ(true,RemoveAll(work));
}
#endif // TEST_FIND_001

#ifdef TEST_FIND_002
TEST(TEST_CASE_NAME,TEST_NUMBER(002))
{
    if(Exists(work))
    EXPECT_EQ(true,RemoveAll(work));

    CreateTestWorkspace();
    const path location   = work/"workspace";
    const path symptoms[] ={ "boost","gtest","tools" };
    const path workspace  = FindNext(location,symptoms);
    const bool success    = workspace == work/"workspace/external/msvc2013";
    EXPECT_EQ(true,success);

    if(Exists(work))
        EXPECT_EQ(true,RemoveAll(work));
}
#endif // TEST_FIND_002

#ifdef TEST_FIND_003
#endif // TEST_FIND_003

#ifdef TEST_FIND_004
#endif // TEST_FIND_004

#ifdef TEST_FIND_005
#endif // TEST_FIND_005

#ifdef TEST_FIND_006
#endif // TEST_FIND_006

#ifdef TEST_FIND_007
#endif // TEST_FIND_007

#ifdef TEST_FIND_008
#endif // TEST_FIND_008

#ifdef TEST_FIND_009
#endif // TEST_FIND_009

#ifdef TEST_FIND_010
#endif // TEST_FIND_010

#ifdef TEST_FIND_011
#endif // TEST_FIND_011

#ifdef TEST_FIND_012
#endif // TEST_FIND_012

#ifdef TEST_FIND_013
#endif // TEST_FIND_013

#ifdef TEST_FIND_014
#endif // TEST_FIND_014

#ifdef TEST_FIND_015
#endif // TEST_FIND_015

#ifdef TEST_FIND_016
#endif // TEST_FIND_016

#ifdef TEST_FIND_017
#endif // TEST_FIND_017

#ifdef TEST_FIND_018
#endif // TEST_FIND_018

#ifdef TEST_FIND_019
#endif // TEST_FIND_019

#ifdef TEST_FIND_020
#endif // TEST_FIND_020

#ifdef TEST_FIND_021
#endif // TEST_FIND_021

#ifdef TEST_FIND_022
#endif // TEST_FIND_022

#ifdef TEST_FIND_023
#endif // TEST_FIND_023

#ifdef TEST_FIND_024
#endif // TEST_FIND_024

#ifdef TEST_FIND_025
#endif // TEST_FIND_025

#ifdef TEST_FIND_026
#endif // TEST_FIND_026

#ifdef TEST_FIND_027
#endif // TEST_FIND_027

#ifdef TEST_FIND_028
#endif // TEST_FIND_029

#ifdef TEST_FIND_030
#endif // TEST_FIND_030

#ifdef TEST_FIND_031
#endif // TEST_FIND_031

#ifdef TEST_FIND_032
#endif // TEST_FIND_032

#endif



